{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}
{% import "_macros.html" as macros %}

{% block page_title %}{% if blog.id == 998 %}关于本站{% else %}{{ blog.name }}{% endif %}{% endblock %}

{% block about %}{% if blog.id == 998 %}"active"{% endif %}{% endblock %}

{% block page_content %}

<div class="col-md-8 blog-post">    
    <h2 class="blog-post-title">{% if blog.id == 998 %}{% else %}{{ blog.name }}{% endif %}</h2>
    {% if blog.id == 998 %}
    {% else %}
        {% include "_labels.html" %}
        <h5></h5>
    {% endif %}
    {% if blog.id != 998 %}
    <p class="lead blog-description">{{ moment(blog.create_at).format('LL hh:mm:ss') }}&nbsp;
        {% if current_user.is_authenticated %}
            {% if blog.is_collected(current_user) %}
                <a href="{{ url_for('manage.disable_collect', id=blog.id, info='blog') }}"><span class="glyphicon glyphicon-heart" aria-hidden="true"></span>&nbsp;取消收藏</a>&nbsp;  
            {% else %}
                <a href="{{ url_for('manage.enable_collect', id=blog.id, info='blog') }}"><span class="glyphicon glyphicon-heart-empty" aria-hidden="true"></span>&nbsp;收藏</a>&nbsp;
            {% endif %}
        {% endif %}
        <a href="#comments"><span class="glyphicon glyphicon-comment" aria-hidden="true"></span>&nbsp;评论({{ blog.comments.count() }})</a> &nbsp;
        {% if current_user.is_administrator() %}<a href="{{ url_for('manage.edit_blog', id=blog.id) }}">编辑</a>{% endif %}
    </p>
    <p >
        {% if blog.summary_html %}
            {{ blog.summary_html | safe }}
        {% else %}
            {{ blog.summary  }}
        {% endif %}     
    </p>
    <hr>
    {% endif %}
    <p >
        {% if blog.content_html %}
            {{ blog.content_html | safe }}
        {% else %}
            {{ blog.content  }}
        {% endif %}         
    </p>
    <p >
        {% if blog.upload_file %}
        <a href="{{ url_for('main.download', id=blog.id) }}">附件下载:  + {{ blog.upload_real_name }}</a>
        {% endif %}
    </p>
</div>
{% if blog.id != 998 %}
    <h3 class="col-md-8" id="comments"><hr><b>『评论』</b></h3>

    {% if current_user.is_authenticated %}
    <div class="col-md-7 comment-form">
        <form method='POST' role="form">
                {{ form.hidden_tag() }}
                {{ form.content.label }} {{ form.content(class="form-control", rows="3") }}
                <br>
                {{ form.submit(class="btn btn-default") }}
        </form>
    </div>
    {% else %}
    <div class="col-md-7 nocomment">
        <span><h4><hr>想评论此文章？请先<a href="{{ url_for('auth.login') }}">登录</a>～</h4></span>
    </div>
    {% endif %}

    {% include "_comments.html" %}

    {% if pagination and comments %}
    <div class="col-md-7 pagination-comment">
        <div class="pagination-Nav">
            {{ macros.pagination_widget(pagination, 'main.blog', fragment='#comments', id=blog.id) }}
        </div>
    </div>
    {% endif %}
{% endif %}   
{% endblock %}